package lee.vioson.ebook.ui.components

import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier

/**
 *Author:viosonlee
 *Date:2023/6/16
 *DESCRIPTION:
 */
@Composable
fun Loading(
    modifier: Modifier = Modifier,
    progressModifier:Modifier = Modifier.fillMaxSize(fraction = 0.5f),
    showLoading: Boolean,
    content: @Composable () -> Unit
) {
    Box(modifier = modifier, contentAlignment = Alignment.Center) {
        if (showLoading)
            CircularProgressIndicator(modifier = progressModifier)
        else CompositionLocalProvider(content = content)
    }
}